#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;

#define in read()
#define pii pair<int,int>
#define fi first
#define se second
#define FILE(x) freopen(x".in","r",stdin);\
	freopen(x".out","w",stdout);
#define pb push_back

int read(){
	int x = 0,sgn = 1;char ch = getchar();
	for(;!isdigit(ch);ch = getchar()) if(ch == '-') sgn = -1;
	for(;isdigit(ch);ch = getchar()) x = (x<<1)+(x<<3)+(ch^48);
	return x*sgn;
}

const int N = 1e6+10;
const int mod = 1e9+7;

db ffac[N];
int n,k;
ll fac[N],inv[N],ans;

ll qp(ll x,int t){ll res=1;for(;t;t>>=1,x=x*x%mod)if(t&1) res = res * x % mod;return res;}

ll C(int x,int y){if(x < 0 || y < 0 || x < y) return 0;return fac[x] * inv[y] % mod * inv[x-y] % mod;}

db DC(int x,int y){return ffac[x] - ffac[y] - ffac[x-y];}

struct bino{
	int x,y;db val;
	friend bool operator < (bino a,bino b){
		return a.val < b.val;
	}
};

priority_queue<bino> q;

int main (){
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
#endif
	for(int i = (fac[0] = 1);i < N;i++) fac[i] = fac[i-1] * i % mod; inv[N-1] = qp(fac[N-1],mod-2);
	for(int i = N - 2;i >= 0;i--) inv[i] = inv[i + 1] * (i + 1) % mod;
	for(int i = 1;i < N;i++) ffac[i] = ffac[i-1] + log(i);
	n = in,k = in;
	for(int i = 0;i <= n;i++)
		q.push((bino){n,i,DC(n,i)});
	while(q.size() && k){
		bino x = q.top(); k--; q.pop();
		ans = (ans + C(x.x,x.y)) % mod;
		if(x.x > 0) q.push((bino){x.x-1,x.y,DC(x.x-1,x.y)});
	}
	printf("%lld\n",ans);
	return 0;
}

